<?php

class mysql {
    public function connect() {
        echo 'connect db';
    }
}

class mysqlProxy {
    public $runObj;

    public function __construct($objName) {
        $this->runObj = new $objName();
    }

    public function __call($name, $args) {
        $reflectClass = new ReflectionClass($this->runObj);
        $method = $reflectClass->getMethod($name);
        if ($method->isPublic() && !$method->isAbstract()) {
            echo "before execute $name\n";
            $method->invoke($this->runObj, $args);
            echo "\nafter execute $name";
        }
    }
}

$obj = new mysqlProxy('mysql');
$obj->connect('db');
